<?php
/**
 * Created by PhpStorm.
 * User: tsy
 * Date: 2017/6/15
 * Time: 14:49
 */
namespace Admin\Controller\Remark;
use Think\Controller;
use Admin\Controller\Common\BaseController;

class BorrowremarkController extends BaseController
{
    public function add_borrow_remark(){
        $borrow_id=I("get.borrow_id");
        $borrow_remark=D("BorrowRemark");
        $remark_user_array=$borrow_remark->select_remark_user();

        $this->assign("borrow_id",$borrow_id);
        $this->assign("remark_user_array",json_encode($remark_user_array));
        $this->display();
    }

    public function insert_borrow_remark(){
        $borrow_id=I("post.borrow_id");
        $remark_user=I("post.remark_user");
        $remark_content=I("post.remark_content");

        $borrow_remark=D("BorrowRemark");
        $remark_result=$borrow_remark->insert_borrow_remark($remark_content,$remark_user,$borrow_id);
        if($remark_result!=0){
            $result['state']=1;
            $result['message']="新增备注成功";
        }else{
            $result['state']=2;
            $result['message']="新增备注失败";
        }
        $this->ajaxReturn($result);
    }

    public function update_borrow_remark(){
        $remark_id=I("get.remark_id");
        $borrow_remark=D("BorrowRemark");
        $remark_user_detail=$borrow_remark->select_remark_byid($remark_id);
        $remark_user_array=$borrow_remark->select_remark_user();
        $this->assign("remark_user_array",json_encode($remark_user_array));
        $this->assign("remark_user_detail",json_encode($remark_user_detail[0]));
        $this->display();
    }

    public function edit_borrow_remark(){
        $remark_id=I("post.remark_id");
        $remark_user=I("post.remark_user");
        $remark_content=I("post.remark_content");

        $borrow_remark=D("BorrowRemark");
        $remark_result=$borrow_remark->update_borrow_remark($remark_content,$remark_user,$remark_id);
        if($remark_result!=0){
            $result['state']=1;
            $result['message']="修改备注成功";
        }else{
            $result['state']=2;
            $result['message']="修改备注失败";
        }
        $this->ajaxReturn($result);
    }
}